/*
 * @Author: Y先森
 * @Date: 2023-04-11 16:01:55
 * @LastEditors: y && 250048395@qq.com
 * @LastEditTime: 2023-05-09 11:00:10
 * @FilePath: \y-website\src\store\getters.js
 */
import { isMobileTerminal } from '@/utils/flexible'

export default {
    /**
     * 【技术分享】 - 分类数据源
     */
    craftShareCategorys: (state) => state.category.craftShareCategorys,
    /**
     * category选中项
     */
    currentCraftShareCategory:(state) => state.app.currentCraftShareCategory,
    /**
     * category选中项下标
     */
    currentCraftShareCategoryIndex: (state, getters) => {
        if(getters.craftShareCategorys.length){
            return getters.craftShareCategorys.findIndex(
                (item) => item.id == getters.currentCraftShareCategory.id
            )
        }
    },
    /**
     * 【灵感创作】 - 分类数据源
     */
    creationCategorys: (state) => state.category.creationCategorys,
    /**
     * category选中项
     */
    currentCreationCategory:(state) => state.app.currentCreationCategory,
    /**
     * category选中项下标
     */
    currentCreationCategoryIndex: (state, getters) => {
        if(getters.creationCategorys.length){
            return getters.creationCategorys.findIndex(
                (item) => item.id == getters.currentCreationCategory.id
            )
        }
    },
    /**
     * 【设计展示】 - 分类数据源
     */
    designCategorys: (state) => state.category.designCategorys,
    /**
     * category选中项
     */
    currentDesignCategory:(state) => state.app.currentDesignCategory,
    /**
     * category选中项下标
     */
    currentDesignCategoryIndex: (state, getters) => {
        if(getters.designCategorys.length){
            return getters.designCategorys.findIndex(
                (item) => item.id == getters.currentDesignCategory.id
            )
        }
    },
    /**
     * menuDate 菜单数据
     */
    menuDate: (state) => state.app.menuDate,
    /**
     * 获取设备宽度
     */
    asideWidth: (state) => state.app.asideWidth,
    /**
     * 菜单数据
     */
    menus:(state) => state.app.menus,
    /**
     * 当前主题
     */
    themeType: (state) => state.theme.themeType,
    /**
     * asideWidth侧边宽度
     */
    asideWidth: (state) => state.app.asideWidth,
    /**
     * 搜索记录
     */
    historys: (state) => state.search.historys,
    /**
     * 搜索文本
     */
    searchText: (state) => state.app.searchText,
    /**
     * token
     */
    token: (state) => state.user.token,
    /**
     * 获取用户信息
     */
    userInfo: (state) => state.user.userInfo,
    // 路由跳转方式
    routerType: (state) => {
        // 在 PC 端下，永远为 none
        if (!isMobileTerminal.value) {
            return 'none'
        }
        return state.app.routerType
    }
}
